/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Goals.Calculations;

import Current.Account;

/**
 * @author Fork
 */
public class SpyOffenseGoals {

    private Integer spyOffenseGoal;
    private Account account;

    public SpyOffenseGoals(Integer spyOffenseGoals, Account account) {
        this.spyOffenseGoal = spyOffenseGoals;
        this.account = account;
    }

    public SpyOffenseGoals(Account account) {
        this.spyOffenseGoal = account.getStats().getSpyOffense();
        this.account = account;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    public Integer getSpyOffenseGoals() {
        return spyOffenseGoal;
    }

    public void setSpyOffenseGoals(Integer spyOffenseGoals) {
        this.spyOffenseGoal = spyOffenseGoals;
    }

    Integer calcNeededFEType1Units() {
        Integer result;
        Integer gap = spyOffenseGoal - account.getStats().getSpyOffense();
        Integer fullyEquipedBoost = account.getUnits().getSpies().getSpyOffenseIncrease() + account.getArmories().getSpyOffArmory().getSetSpyOffenseBonus();

        Double multiplier = 1 + ((double) account.getClassDT().spyOffenseBoost() + account.getRace().spyOffenseBoost() + account.getStructures().getSpyOffFortBonus() + account.getPoints().getIntelligence()) / 100;

        result = (int) Math.rint(gap / (multiplier * fullyEquipedBoost));
        return result;
    }

    Integer calcNeededFEType2Units() {
        Integer result;
        Integer gap = spyOffenseGoal - account.getStats().getSpyOffense();
        Integer fullyEquipedBoost = account.getUnits().getAssassins().getSpyOffenseIncrease() + account.getArmories().getSpyOffArmory().getSetSpyOffenseBonus();

        Double multiplier = 1 + ((double) account.getClassDT().spyOffenseBoost() + account.getRace().spyOffenseBoost() + account.getStructures().getSpyOffFortBonus() + account.getPoints().getIntelligence()) / 100;

        result = (int) Math.rint(gap / (multiplier * fullyEquipedBoost));
        return result;
    }

    Integer calcNeededFEType3Units() {
        Integer result;
        Integer gap = spyOffenseGoal - account.getStats().getSpyOffense();
        Integer fullyEquipedBoost = account.getUnits().getInfiltrators().getSpyOffenseIncrease() + account.getArmories().getSpyOffArmory().getSetSpyOffenseBonus();

        Double multiplier = 1 + ((double) account.getClassDT().spyOffenseBoost() + account.getRace().spyOffenseBoost() + account.getStructures().getSpyOffFortBonus() + account.getPoints().getIntelligence()) / 100;

        result = (int) Math.rint(gap / (multiplier * fullyEquipedBoost));
        return result;
    }

//    public Integer calcNeededFEType4Units() {
//        Integer result;
//        Integer gap = spyOffenseGoal - account.getStats().getSpyOffense();
//        Integer fullyEquipedBoost = account.getUnits().getSpies().getSpyOffenseIncrease() + account.getArmories().getSpyOffArmory().getSetSpyOffenseBonus();
//
//        Double multiplier = 1 + new Double(account.getClassDT().spyOffenseBoost() + account.getRace().spyOffenseBoost() + account.getStructures().getSpyOffFortBonus() + account.getPoints().getIntelligence()) / 100;
//
//        result = (int) Math.rint(gap / (multiplier * fullyEquipedBoost));
//        return result;
//    }

    public Integer calcNeededType1UnitGold() {
        Integer neededUnits = calcNeededFEType1Units();

        Integer costPerFullSetUnit = account.getArmories().getSpyOffArmory().getSetCost() + account.getUnits().getSpies().getCostToTrain();

        return neededUnits * costPerFullSetUnit;
    }

    public Integer calcNeededType2UnitGold() {
        Integer neededUnits = calcNeededFEType2Units();

        Integer costPerFullSetUnit = account.getArmories().getSpyOffArmory().getSetCost() + account.getUnits().getAssassins().getCostToTrain();

        return neededUnits * costPerFullSetUnit;
    }

    public Integer calcNeededType3UnitGold() {
        Integer neededUnits = calcNeededFEType3Units();

        Integer costPerFullSetUnit = account.getArmories().getSpyOffArmory().getSetCost() + account.getUnits().getInfiltrators().getCostToTrain();

        return neededUnits * costPerFullSetUnit;
    }

//    public Integer calcNeededType4UnitGold() {
//        Integer neededUnits = calcNeededFEType4Units();
//
//        Integer costPerFullSetUnit = account.getArmories().getDefArmory().getSetCost() + account.getUnits().getRoyalGuards().getCostToTrain();
//
//        return neededUnits * costPerFullSetUnit;
//    }
}
